#include "../include/scorewidget.h"

#include <QLabel>
#include <QHBoxLayout>
#include <QVBoxLayout>

ScoreWidget::ScoreWidget(QWidget *parent) : QWidget(parent),score(0),numRingsRemoved(0)
{
	QPalette p;
	p.setColor(QPalette::WindowText,Qt::white);

	scoreLabel = new QLabel(tr("Score :"),this);
	scoreLabel->setPalette(p);

	scoreDataLabel = new QLabel(tr("0"),this);
	scoreDataLabel->setPalette(p);

	numRingsLabel = new QLabel(tr("Rings removed :"),this);
	numRingsLabel->setPalette(p);

	numRingsDataLabel = new QLabel(tr("0"),this);
	numRingsDataLabel->setPalette(p);

	QHBoxLayout *hLay1 = new QHBoxLayout;
	hLay1->addWidget(scoreLabel,0,Qt::AlignRight);
	hLay1->addWidget(scoreDataLabel,0,Qt::AlignLeft);

	QHBoxLayout *hLay2 = new QHBoxLayout;
	hLay2->addWidget(numRingsLabel,0,Qt::AlignRight);
	hLay2->addWidget(numRingsDataLabel,0,Qt::AlignLeft);

	QVBoxLayout *mainLayout = new QVBoxLayout;
	mainLayout->addLayout(hLay1);
	mainLayout->addLayout(hLay2);

	setFixedHeight(100);
	setLayout(mainLayout);
	show();
}

void ScoreWidget::ringsRemoved(int n)
{
	numRingsRemoved += n;
	numRingsDataLabel->setText(QString::number(numRingsRemoved));

	switch(n){
		case 2:
			score += 25;
			break;
		case 3:
			score += 37;
			break;
		case 4:
			score += 50;
			break;
		default:
			score += 10;
			break;
	}

	scoreDataLabel->setText(QString::number(score));
}
